package com.fenghongzhang.day006;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;

import com.fenghongzhang.day006.fragment.OneFragment;
import com.fenghongzhang.day006.fragment.ThreeFragment;
import com.fenghongzhang.day006.fragment.TwoFragment;

import java.util.ArrayList;
import java.util.List;

public class Main2Activity extends AppCompatActivity {
    private ViewPager vp2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);


        //2
        vp2 = (ViewPager) findViewById(R.id.vp2);

        //3
//        List<String> list = new ArrayList<>();
//        list.add("第一个");
//        list.add("第二个");
//        list.add("第三个");

        //3
        List<Fragment> list = new ArrayList<>();
        list.add(new OneFragment());
        list.add(new ThreeFragment());
        list.add(new TwoFragment());

//        for (int i = 1; i <= 3; i++) {
//            BlankFragment2 blankFragment2 = new BlankFragment2();
//            Bundle bundle = new Bundle();
//            bundle.putString("name","第"+i+"个");
//            blankFragment2.setArguments(bundle);
//
//            list.add(blankFragment2);
//        }
        //4
        MyFragmentAdapter myFragmentAdapter = new MyFragmentAdapter(getSupportFragmentManager(),list);

        vp2.setAdapter(myFragmentAdapter);


    }
}
